package com.huluobo.mvvm_base.viewmodel;

import androidx.lifecycle.ViewModel;

import com.huluobo.mvvm_base.model.BaseRepo;

/**
 * Created by LC on 2024/3/22.
 */
public abstract class BaseViewModel<Repo extends BaseRepo> extends ViewModel {
    //数据仓库
    protected Repo repo;

    public BaseViewModel() {
        repo = createRepo();
    }

    //每一个ViewModel都需要有个对应的Repo,比如:LoginViewModel,需要有一个对应的LoginRepo
    //这个createRepo的方法就是绑定(new)一个ViewModel对应的Repo
    protected abstract Repo createRepo();

}
